package com.qf.controller;

import com.qf.entity.Result;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    //@RequiresRoles("开发工程师") 判断用户是否拥有某角色

    @RequiresPermissions(value={"sys:user:query","sys:user:del"},logical = Logical.OR)  //判断用户是否拥有某权限 value默认情况下必须拥有所有的角色和权限
    @RequestMapping("/query")
    public Result query(){
        return new Result(0,"查询成功");
    }
    @RequiresRoles("管理员")
    @RequiresPermissions("sys:user:add")
    @RequestMapping("/add")
    public Result add(){
        return new Result(0,"添加成功");
    }
    @RequestMapping("/test")
    @ResponseBody
    public Result update(){
        return new Result(0,"修改操作");
    }
}
